package weathercase.observer;

import weathercase.subject.Subject;

/**
 * description:
 *
 * @author yuanmenglv on 2019/11/25
 */
public class CurrentConditionsDisplay implements Observer, Display {
    private float temperature;
    private float humidity;
    private float pressure;
    private Subject weatherData;

    public CurrentConditionsDisplay(Subject weatherData){
        this.weatherData = weatherData;
        weatherData.registerObserver(this);
    }
    @Override
    public void disPlay() {
        System.out.printf("CurrentConditionsDisplay观察到当前:\n\t温度为%.2f\n\t湿度为%.2f\n\t气压为%.2f\n", temperature, humidity, pressure );
    }

    @Override
    public void update(float temperature, float humidity, float pressure) {
        this.temperature = temperature;
        this.humidity = humidity;
        this.pressure = pressure;
        dataChange();
    }

    private void dataChange(){
        disPlay();
    }
}
